﻿using ContactSMS.Domain.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;

namespace ContactSMS.Infrastructure.Configs
{
    public class ContactConfig : IEntityTypeConfiguration<Contact>
    {
        public void Configure(EntityTypeBuilder<Contact> builder)
        {
            builder.ToTable($"T_{nameof(Contact)}", t => t.HasComment("联系人"));
            builder.HasKey(t => t.Id);
            builder.Property(t => t.UserId).HasComment("用户id").HasDefaultValue(0);
            builder.Property(t => t.Name).IsRequired().HasComment("姓名");
            builder.Property(t => t.Company).HasComment("公司");
            builder.Property(t => t.Position).HasComment("职位");
            builder.Property(t => t.Note).HasComment("备注");
            builder.Property(t => t.Initial).HasComment("首字母");
            builder.Property(t => t.PinYin).HasComment("拼音");
            builder.Property(t => t.CreatTime).HasComment("创建时间");
            builder.Property(t => t.UpdateTime).HasComment("更新时间");
            //忽略
            //builder.Ignore(c => c.Phones);
        }
    }
}
